# enCode.py

def caesar_cipher(input_str, shift):    #实现凯撒加密算法
    output = ''
    for char in input_str:
        if char.isalpha():
            shifted = ord(char) + shift
            if char.islower():
                if shifted > ord('z'):
                    shifted -= 26
                elif shifted < ord('a'):
                    shifted += 26
            elif char.isupper():
                if shifted > ord('Z'):
                    shifted -= 26
                elif shifted < ord('A'):
                    shifted += 26
            output += chr(shifted)
        else:
            output += char
    return output
